
<%@page import="com.netcracker.DAO.Template"%>
<%@page import="java.util.ArrayList"%>
<%@page import="com.netcracker.DAO.ConstClass"%>
<%@page import="com.netcracker.DAO.TemplateDAO"%>
<%@ page import="com.netcracker.jsp.UniPage" %>
<%@ page import="java.math.BigInteger" %>
<%@ page import="com.netcracker.jsp.RedirectException" %>
<%@ page import="com.netcracker.jsp.PageDesign" %>
<%@ page import="com.netcracker.jsp.html.Code" %>
<%@ page import="com.netcracker.jsp.*" %>


<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%!
    public class ThisPage extends com.netcracker.jsp.ModernPage {

        private String word = "";

        public ThisPage() {
            // just example
            setPageUrl("/practice/aplha");
        }

        protected void parseParameters() {
            word = getParameter("word");
        }

        protected void init() throws Exception {
            // This block will init a NC Design (NC Header and navigation path).

            ModernDesign theDesign = makeDesign();
            NavigationPath navigationPath = new UniPath();

            setPageInfo("some path");
            navigationPath.addItem("some path");
            theDesign.setNavigationPath(navigationPath);
            setPageDesign(theDesign);
        }

        protected void printWindowContent() throws Exception {
            //method for visual representation
            out.println("Just " + word + " \"Hello World!\"");
            TemplateDAO templateDAO = new TemplateDAO();
            ArrayList<Template> listOfInternetProducts = templateDAO.getTemplates(ConstClass.INTERNET_CATEGORY_ID);
            ArrayList<Template> listOfTVProducts = templateDAO.getTemplates(ConstClass.TV_CATEGORY_ID);
            ArrayList<Template> listOfPhoneProducts = templateDAO.getTemplates(ConstClass.PHONE_CATEGORY_ID);

            HttpServletRequest req = getRequest();
            HttpServletResponse resp = getResponse();

//            req.setAttribute("listOfInternetProducts", listOfInternetProducts);
//            req.setAttribute("listOfTVProducts", listOfTVProducts);
//            req.setAttribute("listOfPhoneProducts", listOfPhoneProducts);

            
            req.getSession().setAttribute("list", listOfInternetProducts);
            RequestDispatcher dispatcher = req.getRequestDispatcher("/alpha/index.jsp?content=order");
            dispatcher.forward(req, resp);
//            RequestDispatcher rd =  req.getRequestDispatcher("/alpha/index.jsp?content=order");
//            rd.forward(req, resp);
            
//            throw new RedirectException("/alpha/index.jsp?content=order");

//            resp.sendRedirect("/alpha/index.jsp?content=order");

        }

        protected void execute() throws Exception {
            // method for logic implementat        //            TemplateDAO templateDAO = new TemplateDAO();
//            ArrayList<Template> listOfInternetProducts = templateDAO.getTemplates(ConstClass.INTERNET_CATEGORY_ID);
//            ArrayList<Template> listOfTVProducts = templateDAO.getTemplates(ConstClass.TV_CATEGORY_ID);
//            ArrayList<Template> listOfPhoneProducts = templateDAO.getTemplates(ConstClass.PHONE_CATEGORY_ID);
//            
//            HttpServletRequest req = getRequest();
//            HttpServletResponse resp = getResponse();
//            
//            req.setAttribute("listOfInternetProducts", listOfInternetProducts);
//            req.setAttribute("listOfTVProducts", listOfTVProducts);
//            req.setAttribute("listOfPhoneProducts", listOfPhoneProducts);
        }
    }
%>
<%
    ThisPage thePage = new ThisPage();
    thePage.setPageContext(pageContext);
//    try {
    thePage.debugSecureService();
//        TemplateDAO templateDAO = new TemplateDAO();
//        ArrayList<Template> listOfInternetProducts = templateDAO.getTemplates(ConstClass.INTERNET_CATEGORY_ID);
//        ArrayList<Template> listOfTVProducts = templateDAO.getTemplates(ConstClass.TV_CATEGORY_ID);
//        ArrayList<Template> listOfPhoneProducts = templateDAO.getTemplates(ConstClass.PHONE_CATEGORY_ID);
//
//        HttpServletRequest req = request; //getRequest();
//        HttpServletResponse resp = response; //getResponse();
//
//        req.setAttribute("listOfInternetProducts", listOfInternetProducts);
//        req.setAttribute("listOfTVProducts", listOfTVProducts);
//        req.setAttribute("listOfPhoneProducts", listOfPhoneProducts);
//
//        RequestDispatcher rd = request.getRequestDispatcher("/alpha/order.jsp");
//        rd.forward(request, response);
//        getServletContext().getRequestDispatcher("/alpha/order.jsp");//.forward(req, resp);
//            sendRedirect
//            request.setAttribute(string, o);
//    } finally {
//    }
%>

